import java.util.Scanner;

/**
 * Created by IntelliJ IDEA.
 * User: zm
 * Date: 2023/5/9
 */
public class Demo30 {
    static int n;
    static int N = 20;
    static char g[][] = new char[N][N];
    static boolean[] col = new boolean[N];
    static boolean[] dg = new boolean[N];
    static boolean[] udg = new boolean[N];
    static void dfs(int  u){
        if(u == n){
            for(int i = 0; i < n; i++){
                for(int j = 0; j < n; j++)
                    System.out.print(g[i][j]);
                System.out.println();
            }
            System.out.println();
            return;
        }
        for(int i = 0; i < n; i++){
            if(!col[i] && !dg[u + i] && !udg[n - u + i]){
                g[u][i] = 'Q';
                col[i] = dg[u + i] = udg[n - u + i] = true;
                dfs(u + 1);
                col[i] = dg[u + i] = udg[n - u + i] = false;
                g[u][i] = '.';
            }
        }
    }
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        n = scan.nextInt();
        for(int i = 0; i < n; i++)
            for(int j = 0; j < n; j++)
                g[i][j] = '.';
        dfs(0);

    }
//    static int n;
//    static int[] path = new int[10];
//    static boolean[] st = new boolean[10];
//    public static void dfs(int u){
//        if(u == n){
//            for(int i = 0 ;i < n; i++) System.out.print(path[i] + " ");
//            System.out.println();
//            return;
//        }
//        for(int i = 1; i <= n; i++){
//            if(!st[i]){
//                path[u] = i;
//                st[i] = true;
//                dfs(u + 1);
//                path[u] = 0;
//                st[i] = false;
//            }
//        }
//    }
//    public static void main(String[] args) {
//        Scanner scan = new Scanner(System.in);
//        n = scan.nextInt();
//        dfs(0);
//    }
}
